from odoo import models, fields, api, _
from odoo.exceptions import UserError

import logging


_logger = logging.getLogger(__name__)


class AccountInvoice(models.Model):
    _inherit = "account.invoice"

    @api.multi
    def change_state_to_draft(self):
        for record in self:
            record.state = 'draft'
            record.move_name = False
